<?php


namespace utils;


class PcrUtils {

    public static function getDayStartAt($now = null) {
        if (is_null($now)) {
            $now = time();
        }
        $h = date('H', $now);
        if ($h >= 0 && $h <= 4) {
            return strtotime('-1 day', strtotime(date('Y-m-d', $now))) + 3600 * 5;
        } else {
            return strtotime((date('Y-m-d', $now) . " 05:00:00"));
        }
    }

    public static function getDayEndAt($now = null) {
        return self::getDayStartAt($now) + 86400 - 1;
    }

}
